package com.lh1010.s3.service;

import com.lh1010.s3.repository.entity.McUser;
import com.lh1010.s3.repository.mapper.McUserMapper;
import com.lh1010.s3.repository.mapper.TestMapper;
import com.lh1010.s3.vo.McUserVo;
import com.zielsmart.web.basic.exception.ValidateException;
import com.zielsmart.web.basic.util.ConvertUtils;
import org.beetl.sql.core.DynamicSqlManager;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TestService {
    @Resource
    private DynamicSqlManager dynamicSqlManager;
    @Resource
    private McUserMapper mcUserMapper;
    @Resource
    private TestMapper testMapper;

    public String test1() {
        return "test1";
    }

    public List<McUserVo> getUsers(McUserVo searchVo) {
        return dynamicSqlManager.getMapper(TestMapper.class).getUsers(searchVo);
    }

    public void updateUser(McUserVo mcUserVo) throws ValidateException {
        System.out.println("打印内容： " + mcUserVo.getAid());
        if (1 == 2) {
            throw new ValidateException("测试异常100");
        }
        testMapper.updateTemplateById(ConvertUtils.beanConvert(mcUserVo, McUser.class));
    }
}